<template>
    <div>

        <h1> new page sub </h1>

        <!--  对象要是冒号，字符随意  v-bind可以省略 -->
        <SelectV2 selectName="性别" selectId="sex" v-bind:options="options" ></SelectV2>

        <SelectV2 selectName="性别" selectId="sex" :options="options" v-on:getVal="fromSelectV2"></SelectV2>


        <button v-on:click="test" >test</button>

            <!-- 也可以 -->
         <button @click="test2" >test222</button>

         <InputV2 ></InputV2>

         <!-- 父组件像子组件传值用 props  子组件像父组件传值用 this.$emit -->

    </div>
</template>

<script>

import SelectV2 from '@/components/SelectV2' ;
import InputV2  from '@/components/InputV2' ;

// 子定义组件
export default {
    name:"NewPageSub",
    components:{
        SelectV2,
        InputV2
    },
    data(){
        return {
            options:[{key:'男',val:1},{key:'女',val:0}]
        }
    },
    mounted(){
        const userid = this.$route.params.userId;
        console.log(userid);
    },
    methods:{
        test(){
            this.options.push({key:'人妖',val:2});
        },
        test2(){
            // let sex = this.$refs['sex'];
            // console.log(sex);
        },
        fromSelectV2(data){
            console.log("------fromSelectV2--------"+data);
        }
    }
}
</script>

<style scoped>

</style>